﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_CharAmount : ServerBasePacket
    {
        private byte[] _byte = null;

        public S_CharAmount( int value, ClientThread client )
        {
            buildPacket( value, client );
        }

        private void buildPacket( int value, ClientThread client )
        {
            Account account = new Account();
            account.load( client.getAccountName() );
            int characterSlot = account.getCharacterSlot();
            int maxAmount = Config.DEFAULT_CHARACTER_SLOT + characterSlot;

            writeC( Opcodes.S_OPCODE_CHARAMOUNT );
            writeC( value );
            // writeD(0x00000000);
            // writeD(0x0000);
            writeC( maxAmount ); // max amount
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = getBytes();
            }
            return _byte;
        }

        override public String getType()
        {
            return "[S] S_CharAmount";
        }
    }
}